package practice.adil.encrypordecryp.JavaEncryptionOne;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * Created by 李园 - Adil on 2017/12/19.
 */
public class EncryptionMD5 {

    public byte[] eccrypt(String info) throws NoSuchAlgorithmException {
        // 根据MD5算法生成MessageDigeat对象
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        byte[] srcBytes = info.getBytes();
        // 使用srcByte 更新摘要
        byte[] resultBytes = md5.digest();
        return resultBytes;
    }

    public static void main(String[] args) throws NoSuchAlgorithmException {
        String msg = "admin";
        EncryptionMD5 md5 = new EncryptionMD5();
        byte[] resultByte = md5.eccrypt(msg);
        System.out.println("密文是："+ new String(resultByte));
        System.out.println("明文是"  + msg);
    }
}
